package ai.esc.speedy.admin.user.infrastructure.jwt;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Value;

import java.io.Serializable;

/**
 * @author Rubin
 * @version v1 2020/3/24 11:16
 */
@Value
public class JwtUserInfo  implements Serializable {
    private static final long serialVersionUID = 1L;

    String account;
    String userId;
    String userData;
    String passportId;

    @JsonIgnore
    public JSONObject getUserDataJSONObject() {
        if (StrUtil.isBlank(userData)) {
            throw new RuntimeException("userData is null!");
        }
        return JSONObject.parseObject(userData);
    }
}
